<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeBehind="GridView.aspx.cs" Inherits="www.Insert_GridView" Title="Untitled Page" %>

<%@ Register Assembly="NBusiness" Namespace="NBusiness.Data.Web" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="BeerId"
        DataSourceID="BeerCollectionDS" ShowHeader="true" ShowFooter="true" OnRowDataBound="GridView1_RowDataBound"
        Width="100%">
        <Columns>
            <asp:TemplateField HeaderText="AvailabilityId" SortExpression="AvailabilityId">
                <ItemTemplate>
                    <asp:HyperLink ID="AvailabilityLink" runat="server" NavigateUrl='<%# Eval("AvailabilityId", "~/Search/ByAvailability.aspx?a={0}") %>'></asp:HyperLink>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:DropDownList ID="AvailabilityCollection" runat="server" DataSourceID="AvailabilityCollectionDS"
                        DataTextField="Text" DataValueField="AvailabilityId">
                    </asp:DropDownList>                    
                </FooterTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="BeerId" HeaderText="BeerId" InsertVisible="False" ReadOnly="True"
                SortExpression="BeerId" />
            <asp:TemplateField HeaderText="Alcohol" SortExpression="Alcohol">
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Alcohol") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="Alcohol" runat="server" Width="50"></asp:TextBox>
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="BeerStyleId" SortExpression="BeerStyleId">
                <ItemTemplate>
                    <asp:HyperLink ID="StyleLink" runat="server" NavigateUrl='<%# Eval("BeerStyleId", "~/Search/ByStyle.aspx?s={0}") %>'></asp:HyperLink>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:DropDownList ID="BeerStyleId" runat="server" DataSourceID="BeerStyleCollectionDS"
                        DataTextField="Name" DataValueField="BeerStyleId">
                    </asp:DropDownList>
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="CompanyId" SortExpression="CompanyId">
                <ItemTemplate>
                    <asp:HyperLink ID="CompanyLink" runat="server" NavigateUrl='<%# Eval("CompanyId", "~/Company.aspx?c={0}") %>'></asp:HyperLink>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:DropDownList ID="CompanyId" runat="server" DataSourceID="CompanyCollectionDS"
                        DataTextField="Name" DataValueField="CompanyId">
                    </asp:DropDownList>
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Name" SortExpression="Name">
                <ItemTemplate>
                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="BeerName" runat="server"></asp:TextBox>
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <FooterTemplate>
                    <asp:Button ID="insertBeer" runat="server" Text="Insert" OnClick="insertBeer_Click" />
                </FooterTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <!-- Data Source -->
    <cc1:EntityDataSource ID="BeerCollectionDS" runat="server" AssemblyName="Example.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
        TypeName="BeerBase.Business.BeerCollection" OnSelect="BeerDataSource_Select">
    </cc1:EntityDataSource>
    <cc1:EntityDataSource ID="AvailabilityCollectionDS" runat="server" AssemblyName="Example.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
        TypeName="BeerBase.Business.CachedAvailabilityCollection" OnSelect="AvailDataSource_Select">
    </cc1:EntityDataSource>
    <cc1:EntityDataSource ID="BeerStyleCollectionDS" runat="server" AssemblyName="Example.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
        TypeName="BeerBase.Business.CachedBeerStyleCollection" OnSelect="BeerStyleDataSource_Select">
    </cc1:EntityDataSource>
    <cc1:EntityDataSource ID="CompanyCollectionDS" runat="server" AssemblyName="Example.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
        TypeName="BeerBase.Business.CompanyCollection" OnSelect="CompanyDataSource_Select">
    </cc1:EntityDataSource>    
</asp:Content>